<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:c="http://java.sun.com/jstl/core"
   xmlns:af="http://myfaces.apache.org/trinidad"
   xmlns:afh="http://myfaces.apache.org/trinidad/html"
   xmlns:html="http://www.w3.org/TR/REC-html40">

   <table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
   <colgroup><col /></colgroup>
   
   <tr><td>

   <div class="activityPanelMenuBar">
      <afh:tableLayout width="100%">
         <afh:rowLayout>
            <ui:insert name="activityMenu">
               <afh:cellFormat styleClass="activityDocumentMenu">
                  <af:panelGroupLayout id="attachmentsOp" layout="horizontal" 
                     rendered="#{activityInstanceDialog.withAttachmentSupport}"
                     partialTriggers="lstAttDocId">

                     <f:facet name="separator">
                        <af:spacer width="4px" />
                     </f:facet>
                     <af:outputLabel value="#{activityInstanceDialog.countOfAttachments}
                        #{activityInstanceDialog.countOfAttachments == 1 ?
                         localeBundle.document : localeBundle.documents}"
                         for="lstAttDocId"
                         id="lblAttDocId" />
                     <af:selectOneChoice id="lstAttDocId" required="false"
                        unselectedLabel="None" autoSubmit="true"
                        partialUpdate="btnAttShow"
                        value="#{activityInstanceDialog.selectedAttachment}"
                        disabled="#{!activityInstanceDialog.withAttachments}"
                        simple="true" valuePassThru="true">
                        <c:forEach var="doc"
                           items="#{activityInstanceDialog.attachments}">
                           <f:selectItem
                              itemLabel="#{not empty doc.displayName ? doc.displayName : doc.id}"
                              itemValue="#{doc.id}" />
                        </c:forEach>
                     </af:selectOneChoice>

                     <af:spacer width="4px" />

                     <c:choose>

                        <c:when
                           test="#{activityInstanceDialog.withAttachmentUrlProvider}">

                           <af:goLink
                              destination="#{activityInstanceDialog.attachmentDetailsUrl}"
                              targetFrame="_blank"
                              text="#{localeBundle.attachmentsShowDetails}"
                              rendered="#{activityInstanceDialog.withAttachmentUrlProvider}"
                              disabled="#{empty activityInstanceDialog.attachmentDetailsUrl or
                                activityInstanceDialog.countOfAttachments eq 0}" />

                           <c:forEach
                              items="#{activityInstanceDialog.attachmentOperations}"
                              var="opKey">
                              <af:spacer width="5" />
                              <af:goLink
                                 text="#{activityInstanceDialog.attachmentOperationLabel[opKey]}"
                                 destination="#{activityInstanceDialog.attachmentOperationUrl[opKey]}"
                                 targetFrame="_blank"
                                 disabled="#{empty activityInstanceDialog.attachmentOperationUrl[opKey]}"
                                 rendered="#{!activityInstanceDialog.isServerSideAttachmentOperation[opKey]}" />
                              <af:commandLink
                                 text="#{activityInstanceDialog.attachmentOperationLabel[opKey]}"
                                 action="#{activityInstanceDialog.performServerSideAttachmentOperation}"
                                 rendered="#{activityInstanceDialog.isServerSideAttachmentOperation[opKey]}"
                                 immediate="true" partialSubmit="true">
                                 <af:setActionListener
                                    from="#{opKey}"
                                    to="#{pageFlowScope.attachmentOperation}" />
                              </af:commandLink>
                           </c:forEach>

                        </c:when>

                        <c:otherwise>
                           <af:navigationPane id="attachmentPane" hint="buttons">
                              <af:commandNavigationItem id="btnAttShow"
                                 disabled="#{!activityInstanceDialog.withAttachments and activityInstanceDialog.countOfAttachments > 0}"
                                 shortDesc="#{localeBundle.attachmentsShowDetails}"
                                 actionListener="#{activityInstanceDialog.showAttachmentDetails}"
                                 styleClass="activityPanelIcon"
                                 immediate="true" partialSubmit="true">
                                 <af:icon id="activityAttachment" 
                                    name="#{activityInstanceDialog.withAttachments ? 'activityAttachment' : 'activityDisabledAttachment'}"/>
                                 <af:setActionListener
                                    from="#{activityInstanceDialog.selectedAttachment}"
                                    to="#{pageFlowScope.attachmentId}" />
                              </af:commandNavigationItem>
                           </af:navigationPane>
                        </c:otherwise>

                     </c:choose>

                  </af:panelGroupLayout>
               </afh:cellFormat>

               <afh:cellFormat styleClass="activityPushServiceMenu">
               	  <af:panelGroupLayout partialTriggers="disablePushService enablePushService">
	                  <af:commandLink id="enablePushService"
	                      partialTriggers="disablePushService enablePushService"
	                      text="#{localeBundle.enablePushService}"
	                      rendered="#{activityInstanceDialog.pushServiceEnabled and not activityInstanceDialog.pushService}">
	                      <af:setActionListener from="#{true}"
	                          to="#{activityInstanceDialog.pushService}"/>
	                  </af:commandLink>
	                  <af:commandLink id="disablePushService"
	                      partialSubmit="true" immediate="true"
	                      text="#{localeBundle.disablePushService}"
	                      rendered="#{activityInstanceDialog.pushServiceEnabled and activityInstanceDialog.pushService}">
	                      <af:setActionListener from="#{false}"
	                          to="#{activityInstanceDialog.pushService}"/>
	                  </af:commandLink>
                  </af:panelGroupLayout>
               </afh:cellFormat>

               <afh:cellFormat halign="right" width="35%" styleClass="activityActionPaneMenu"
                  partialTriggers="activityActionPane:notes">
                  <af:navigationPane id="activityActionPane" hint="buttons">
                     <af:commandNavigationItem id="processHistory"
                        shortDesc="#{localeBundle.processHistory}"
                        disabled="#{activityInstanceDialog.disabled}"
                        action="dialog:processHistory" useWindow="true"
                        launchListener="#{processHistoryDialog.prepareDialog}"
                        windowWidth="640" windowHeight="480" partialSubmit="true"
                        styleClass="activityPanelIcon"
                        immediate="true">
                        <f:attribute name="activityInstanceForProcessHistory" 
                            value="#{activityInstanceDialog.currentActivityInstance}"/>
                        <af:icon name="activityProcessHistory"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="activityDetails"
                        shortDesc="#{localeBundle.activityDetails}"
                        disabled="#{activityInstanceDialog.disabled}"
                        action="dialog:activityDetails" useWindow="true"
                        windowWidth="480" windowHeight="480" partialSubmit="true"
                        launchListener="#{activityMetadataDialog.prepareDialog}"
                        styleClass="activityPanelIcon"
                        immediate="true">
                        <f:attribute name="activityInstanceForDetails" 
                            value="#{activityInstanceDialog.currentActivityInstance}"/>
                        <af:icon name="activityDetails"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="notes"
                        shortDesc="#{localeBundle.activityNotes}"
                        action="dialog:notes" launchListener="#{activityInstanceNotes.prepareDialog}"
                        useWindow="true" windowWidth="640" windowHeight="480"
                        styleClass="activityPanelIcon"
                        partialSubmit="true" immediate="true"
                        returnListener="#{activityInstanceDialog.returnFromNotes}">
                        <af:icon name="#{activityInstanceDialog.notesEmpty ? 'activityEmptyNote' : 'activityNote'}"/>
                        <f:attribute name="currentActivityInstance"
                            value="#{activityInstanceDialog.currentActivityInstance}"/>
                        <f:attribute name="dialogMode" value="addNewNote"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="resubmission"
                        disabled="#{!activityInstanceDialog.withResubmission}"
                        shortDesc="#{localeBundle.resubmission}"
                        action="resubmission"
                        styleClass="activityPanelIcon"
                        partialSubmit="true" immediate="true">
                        <af:icon name="#{activityInstanceDialog.withResubmission ? 'activityResubmission' : 'activityDisabledResubmission'}"/>
                        <af:setActionListener from="#{activityInstanceDialog.resubmissionPage}" 
                            to="#{portalHeader.processPortalSession.currentPage}"/>
                     </af:commandNavigationItem>
                  </af:navigationPane>
               </afh:cellFormat>

               <afh:cellFormat halign="right" width="25%" styleClass="activityWorkflowPaneMenu">
                  <af:navigationPane id="activityWorkflowPane" hint="buttons">
                     <af:commandNavigationItem id="complete-button"
                        onclick="#{onCompleteActivity}"
                        shortDesc="#{localeBundle.complete}"
                        disabled="#{activityInstanceDialog.disabled}"
                        action="#{activityInstanceDialog.completeActivity}"
                        partialTriggers="suspend-button suspend-save-button abort-button"
                        styleClass="activityPanelIcon"
                        partialSubmit="true">
                        <af:icon name="#{activityInstanceDialog.disabled ? 'activityCompleteDisabled' : 'activityComplete'}"/>
                        <af:setActionListener from="#{carnotConstants.activityInstanceState.completed}"
                           to="#{pageFlowScope.activityTargetState}"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="suspend-button"
                        onclick="#{onSuspendActivity}"
                        shortDesc="#{localeBundle.suspend}"
                        disabled="#{activityInstanceDialog.disabled}"
                        action="#{activityInstanceDialog.suspendActivity}"
                        partialTriggers="complete-button suspend-save-button abort-button"
                        partialSubmit="true" immediate="true"
                        styleClass="activityPanelIcon">
                        <af:icon name="#{activityInstanceDialog.disabled ? 'activitySuspendDisabled' : 'activitySuspend'}"/>
                        <af:setActionListener from="#{carnotConstants.activityInstanceState.suspended}"
                           to="#{pageFlowScope.activityTargetState}"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="suspend-save-button"
                        onclick="#{onSuspendAndSaveActivity}"
                        shortDesc="#{localeBundle.suspendAndSave}"
                        disabled="#{activityInstanceDialog.disabled}"
                        action="#{activityInstanceDialog.suspendAndSaveActivity}"
                        partialTriggers="complete-button suspend-button abort-button"
                        partialSubmit="true"
                        styleClass="activityPanelIcon">
                        <af:icon name="#{activityInstanceDialog.disabled ? 'activitySuspendAndSaveDisabled' : 'activitySuspendAndSave'}"/>
                        <af:setActionListener from="#{carnotConstants.activityInstanceState.suspended}"
                           to="#{pageFlowScope.activityTargetState}"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="delegate-button"
                        rendered="#{(not (processPortalSettings.delegationMode eq 'none')) and !pageFlowScope.assemblyLineMode}"
                        onclick="#{onDelegateActivity}"
                        shortDesc="#{commonMsg.delegate}"
                        action="dialog:delegate"
                        launchListener="#{activityInstanceDialog.prepareDelegateActivityDialog}"
                        returnListener="#{activityInstanceDialog.onDelegation}"
                        useWindow="true"
                        partialTriggers="complete-button suspend-button suspend-save-button"
                        styleClass="activityPanelIcon"
                        partialSubmit="true">
                        <af:icon name="#{activityInstanceDialog.disabled ? 'activityDelegateDisabled' : 'activityDelegate'}"/>
                        <af:setActionListener from="#{carnotConstants.activityInstanceState.suspended}"
                           to="#{pageFlowScope.activityTargetState}"/>
                     </af:commandNavigationItem>
                     <af:commandNavigationItem id="abort-button"
                        onclick="#{onAbortActivity}"
                        shortDesc="#{localeBundle.abort}"
                        disabled="#{activityInstanceDialog.abortDisabled}"
                        action="#{activityInstanceDialog.abortActivity}"
                        partialTriggers="complete-button suspend-button suspend-save-button"
                        styleClass="activityPanelIcon"
                        partialSubmit="true" immediate="true">
                        <af:icon name="#{activityInstanceDialog.abortDisabled ? 'activityAbortDisabled' : 'activityAbort'}" />
                        <af:setActionListener from="#{carnotConstants.activityInstanceState.aborted}"
                           to="#{pageFlowScope.activityTargetState}"/>
                     </af:commandNavigationItem>
                  </af:navigationPane>
               </afh:cellFormat>
            </ui:insert>
         </afh:rowLayout>
      </afh:tableLayout>
   </div>
   
   </td></tr>

   <tr><td>

   <ui:insert name="activityHeader">
      <af:spacer height="10" />
   </ui:insert>
   
   </td></tr>
   
   <tr><td style="width: 100%; height: 100%">

   <af:panelBorderLayout id="activityPanel-page"
      binding="#{activityInstanceDialog.ctrlWorkareaPage}"
      inlineStyle="width: 100%; height: 100%;">

      <c:if test="#{('ui:include' == portalHeader.panelIntegrationStrategy) and not empty activityInstanceDialog.panelUrl}">
         <ui:insert name="faceletsActivityPanel">
            <ui:include id="activityPanel-workAreaInclude"
               src="#{activityInstanceDialog.panelUrl}">
               <ui:param name="InCarnotProcessPortal" value="${true}" />
            </ui:include>
         </ui:insert>
      </c:if>

		<c:if test="#{('iframe' == portalHeader.panelIntegrationStrategy)}">

			<iframe id="ipp-embedded-activity-panel" name="ipp-embedded-activity-panel"
                frameborder="0" marginheight="0"
				marginwidth="0" scrolling="auto" src="" align="middle"
				height="100%" width="100%"></iframe>

			<afh:script id="script-workareaRefresh"
				binding="#{activityInstanceDialog.ctrlWorkareaReloadScript}"
				text="#{activityInstanceDialog.workareaReloadCode}"
				rendered="#{('iframe' == portalHeader.panelIntegrationStrategy) and not empty activityInstanceDialog.panelUrl}" />
		</c:if>

   </af:panelBorderLayout>
   
   </td></tr>

   <tr><td>
      <af:spacer height="5" />
   </td></tr>
   
   </table>

</ui:composition>